#include <stdio.h>
#include <math.h>

double det(double a, double b, double c, double d) {return a * d - b * c;}

class vector2D     ///point or vector
{
public:
    double x, y;
public:
    vector2D(double a=0, double b=0):x(a), y(b) {}
    vector2D& set(double xx, double yy) {x = xx, y = yy; return *this;}
    vector2D& operator+=(const vector2D& a) {x += a.x, y += a.y; return *this;}
    vector2D operator+(vector2D a) const {a.x += x, a.y += y; return a;}
    vector2D& operator-=(const vector2D& a) {x -= a.x, y -= a.y; return *this;}
    vector2D operator-(vector2D a) const {a.x = x - a.x, a.y = y - a.y; return a;}
    vector2D& operator*=(double k) {x *= k, y *= k; return *this;}
    vector2D operator*(double k) const {return vector2D(x * k, y * k);}
    vector2D perp() const {return vector2D(-y, x);}
    bool operator==(const vector2D& a) const {return x == a.x && y == a.y;}
    double operator*(const vector2D& a) const {return x * a.x + y * a.y;}     ///dot product
    double operator|(const vector2D& a) const {return x * a.y - y * a.x;}     ///cross product
    double vlen() const {return sqrt(x * x + y * y);}                         ///length of the vector2D
    double get_sin(const vector2D& a) {return ((*this) | a) / (this->vlen() * a.vlen());}
    double get_cos(const vector2D& a) {return ((*this) * a) / (this->vlen() * a.vlen());}
    bool decompose(const vector2D& a, const vector2D& b, double &m, double &n) const;
        ///m*a + n*b = *this, if a|b == 0, return false

};

bool vector2D::decompose(const vector2D& a, const vector2D& b, double &m, double &n) const
{
    if((a | b) == 0) return false;
    double detBase = a | b;
    m = (*this) | b, m /= detBase;
    n = a | (*this), n /= detBase;
    return true;
}

class segment2D
{
public:
    vector2D s, t;
public:
    segment2D(vector2D a, vector2D b):s(a), t(b) {}
    int isIntersect(const segment2D& a) const;
};


int segment2D::isIntersect(const segment2D& a) const
{
    vector2D p(t - s), h1(a.s - s), h2(a.t - s);
    return 0;
}

class matrix2D
{
public:
    double p[2][2];
public:
    double det() const {return p[0][0] * p[1][1] - p[0][1] * p[1][0];}
};

class polygon
{
public:
    vector2D* points;
    int size;
public:

}
